The program will print out:
The value is: 17
LET
StatementLook at the statements:
LET VALUE = 5 LET VALUE = 12 + VALUE
The first statement:
VALUE
.The second statement:
VALUE
.
VALUE
to get the number 5.VALUE
.
A variable can be used on both the LEFT and the RIGHT of the "="
in the same LET
statement.
When it is used on the right, it provides a number used to calculate a result.
When it is used on the left, it says where in memory to save that result.
The two roles are in separate steps, so they don't interfere with each other. Step 2 uses the old value in the variable for the calculation. Then the new value (from the calculation) is put into the variable.
What will the following program print out:
' More example LET statements LET VALUE = 5 PRINT "Value is:", VALUE ' LET VALUE = VALUE + 10 PRINT "Now the value is:", VALUE END